package com.meichis.yndms.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;

import com.meichis.mcsappframework.utils.Tools;
import com.meichis.yndms.service.UpLoadServices;

/**
 * Created by chenhaifei on 2016/9/5.
 */
public class UpLoadReceiver extends BroadcastReceiver {
    @Override
    public synchronized void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals("com.meichis.yndms.intent.UpLoadInfo") && Tools.isConnected(context)) {
            intent.setClass(context, UpLoadServices.class);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                context.startForegroundService(intent);
            } else {
                context.startService(intent);
            }
        }
    }
}
